package com.bizihang.security.core.validate.code;


import java.time.LocalDateTime;

/**
 * 图片验证码对象
 *
 * @author 毕子航 951755883@qq.com
 * @date 2018/08/17
 */
public class ValidateCode {
	String code;
	LocalDateTime expireTime;

	/**
	 * @param code         随机码
	 * @param expireSecond 过期的秒数
	 */
	public ValidateCode(String code, int expireSecond) {
		this.code = code;
		this.expireTime = LocalDateTime.now().plusSeconds(expireSecond);
	}

	/**
	 * @param code       随机码
	 * @param expireTime 过期的时间
	 */
	public ValidateCode(String code, LocalDateTime expireTime) {
		this.code = code;
		this.expireTime = expireTime;
	}

	public String getCode() {
		return code;
	}

	public LocalDateTime getExpireTime() {
		return expireTime;
	}

	public boolean isExpried() {
		return LocalDateTime.now().isAfter(expireTime);
	}
}
